// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "ActiveGameplayEffectHandle.h"
#include "GameplayTagContainer.h"
#include "Kismet/BlueprintAsyncActionBase.h"
#include "ListenCooldownChange.generated.h"


struct FGameplayEffectSpec;
class UAbilitySystemComponent;

/** 携带float的委托 */
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCooldownChangeSignature, float, TimeRemaining);

/**
 * 监听冷却值改变
 */
UCLASS(BlueprintType, meta=(ExposedAsyncProxy="AsyncTask"))
class AURA_API UListenCooldownChange : public UBlueprintAsyncActionBase
{
	GENERATED_BODY()

public:

	/** 冷却开始执行的委托 */
	UPROPERTY(BlueprintAssignable)
	FCooldownChangeSignature CooldownStart;

	/** 冷却结束执行的委托 */
	UPROPERTY(BlueprintAssignable)
	FCooldownChangeSignature CooldownEnd;

	/** 任务函数,返回本任务对象 */
	UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true"))
	static UListenCooldownChange* ListenCooldownChange(UAbilitySystemComponent* InASC, FGameplayTag InCooldownTag);

	/** 结束任务 */
	UFUNCTION(BlueprintCallable)
	void EndTask();



protected:

	UPROPERTY()
	TObjectPtr<UAbilitySystemComponent> ASC = nullptr;

	/** 记录监听的冷却标签 */
	FGameplayTag CooldownTag;

	/** 监听冷却标签的回调函数 */
	void CooldownTagChange(const FGameplayTag InCooldownTag, int32 NewCount) const;

	/** 监听ASC激活GE的回调 */
	void OnActiveEffectAdded(
		UAbilitySystemComponent* InASC, const FGameplayEffectSpec& SpecApplied, FActiveGameplayEffectHandle ActiveHandle
	) const;
};
